<?php

//小站皮肤模块
class Skins_model extends Model {

	function Skins_model()
	{
		parent::Model();	
		$this->load->database();
	}
	
	//皮肤列表
	function lists()
	{
		$lists = array();
		$query = $this->db->from("site_skins")->order_by("id")->get();
		if ($query->num_rows()>0) {
			$lists = $query->result_array();
		}
		return $lists;
	}
	
	//获取小站皮肤设置
	function get_site($siteid) 
	{
		$skins = array();
		$query = $this->db->get_where("site_info", array("siteid"=>$siteid));
		if ($query->num_rows()>0) {
			$row = $query->row_array();
			$skinid = $row["skin"];
			$q = $this->db->get_where("site_skins", array("id"=>$skinid));
			if ($q->num_rows()>0) {
				$skins = $q->row_array();
			}
			//检测背景是否重新设置
			if($row["background"] != "") $skins["background"] = $row["background"];
			//检测链接颜色是否重新设置
			$skins["skincolor"] = "";
			if($row["color"] != "") $skins["skincolor"] = $row["color"];
		}
		//安全检查
		if($skins["background"] == "") $skins["background"] = "background_1.gif";
		if($skins["bannerbg"] == "") $skins["bannerbg"] = "bannerbg_1.gif";
		if($skins["color"] == "") $skins["color"] = "#444444";
		return $skins;
	}
	
	//设置皮肤
	function set()
	{
		
	}
}

/* End of file */